$('document').ready(function(){	
	$( 'textarea#description' ).ckeditor();    
    $.validator.addMethod("logoCheck", function (value, element) {
        return validateLogo();
    }, 'Please upload valid image');
	$('#frmAdd').validate({
            errorClass      : 'error',
            errorElement	: 'span',
    		onfocusout		: false,
    		onkeyup			: false,
    		ignore			: 'input[type="text"]:hidden',
			rules:{
				name:{
					required:true,
					minlength:VL_NAME_MINLENGTH,
					maxlength:VL_NAME_MAXLENGTH
				},
				nickname:{
					required: true,
					minlength:VL_NAME_MINLENGTH,
					maxlength:VL_NAME_MAXLENGTH
				},
				country:{
					required:true,
					minlength:2,
					maxlength:2
				},
                logo:{
                    required: true,
                    logoCheck:true
                },
                short:{
                    required: true,
                    minlength: VL_SHORT_MINLENGTH,
                    maxlength: VL_SHORT_MAXLENGTH,
                },
                description:{
                    required:true,
                    minlength:VL_CONTENT_MINLENGTH
                },
                
				
			},
			messages:{
				name:{
                    required : name_required,
                    minlength: name_minlength,
                    maxlength: name_maxlength
                },
				nickname:{
                    required : nickname_required,
                    minlength: nickname_minlength,
                    maxlength: nickname_maxlength
                },
				country:{
                    required : country_required,
                    minlength: country_minlength,
                    maxlength: country_maxlength                
                },
                logo:{
                    required: logo_required,
                    logoCheck:logo_format
                },
                sshort:{
                    required  : short_required,
                    minlength: short_minlength,
                    maxlength: short_maxlength,
                },
                description:{
                    required:description_required,
                    minlength:description_minlength
                }
			},
			errorPlacement: function(error, element) {
			       error.insertAfter(element); // change this to place error message elsewhere
			}			
	});    
});
function validateLogo() {
    strLogoPath = $('#logo').val();
    if( strLogoPath.length > 0 ) {
        if(validateImage(strLogoPath)) {
            // image size 1MB
            if( validateImageSize(this,IMAGE_SIZE) ){
                return true;
            }
        }
    }
    return false;
}
resetLogo = function(type) {
    if(type==1){ $("#logo").replaceWith($("#logo").clone()); return validateUrl($('#link').val());}
    else { $('#link').val('');return;}
}
